package HOT100;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author 是阿秋啊
 * @date 2022/11/25 15:46
 **/
public class sifangda1 {
    public static void main(String[] args) {
        int[] arr = new int[16];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 16; i++) {
            arr[i] = sc.nextInt();
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 15; i >= 0; i--) {
            if (arr[i] != 0) {
                int n = arr[i];
                for (int j = 0; j < n; j++) {
                    if (i >= 10) {
                        if (i == 15) {
                            sb.append("F");
                        }
                        if (i == 14) {
                            sb.append("E");
                        }
                        if (i == 13) {
                            sb.append("D");
                        }
                        if (i == 12) {
                            sb.append("C");
                        }
                        if (i == 11) {
                            sb.append("B");
                        }
                        if (i == 10) {
                            sb.append("A");
                        }
                    }else{
                        sb.append(i);
                    }
                }
            }
        }
        Long num = Long.parseLong(sb.toString(), 16);
        String s = String.valueOf(num);
        System.out.println(s);
        char[] ch = s.toCharArray();
        int[] tmp = new int[ch.length];
        for (int i = 0; i < ch.length; i++) {
            tmp[i] = ch[i] - '0';
        }
        Arrays.sort(tmp);
        StringBuilder ret = new StringBuilder();
        int start = 0;
        for (int i = 0; i < tmp.length; i++) {
            if (tmp[i] != 0) {
                start = i;
                break;
            }
        }
        for (int i = start; i < tmp.length; i++) {
            ret.append(tmp[i]);
        }
        for (int i = 0; i < start; i++) {
            ret.append(0);
        }
        System.out.println(ret);
    }
}